package com.kyzh.core.adapters

import android.widget.ImageView
import com.bumptech.glide.Glide
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.gushenge.atools.util.setHeight
import com.gushenge.atools.util.setWidth
import com.gushenge.core.beans.Nav
import com.kyzh.core.R
import com.kyzh.core.activities.BackgroundActivity
import com.kyzh.core.utils.dip
import com.kyzh.core.utils.navClickByLogin
import com.kyzh.core.utils.startGameDetailActivity

class NavAdapter(val layout: Int, beans: MutableList<Nav>) : BaseQuickAdapter<Nav, BaseViewHolder>(layout, beans) {
    override fun convert(helper: BaseViewHolder, item: Nav) {
        helper.setText(R.id.tvTitle, item.name)
        val img = helper.getView<ImageView>(R.id.ivIcon)
        Glide.with(context).load(item.icon).into(img)

        helper.itemView.setOnClickListener {
            if (item.gid.isNullOrBlank()) {
                context.navClickByLogin(item)
            } else {
                context.startGameDetailActivity(item.gid)
            }
        }
    }
}